package com.kly.cashmall.utils.system;

import android.os.Build;
import android.view.View;

import com.kly.cashmall.utils.data.DensityUtil;
import com.kly.cashmall.utils.system.StatusBarUtils;

public class BarUtils {

    public  static int paddingHeight;

    public static void setActionBarLayout(View actionBar) {
        setActionBarLayout(actionBar, 50);
    }

    public static void setActionBarLayoutHeight(View actionBar) {
        setActionBarLayout(actionBar, 30);
    }

    public static void setActionBarLayoutFragment(View actionBar) {
        setActionBarLayout(actionBar, 72);
    }

    public static void setActionBarLayout(View actionBar, int sHeight) {
        if (actionBar != null && actionBar.getContext() != null) {
            int height =
                    Build.VERSION.SDK_INT >= 19 ? StatusBarUtils.getStatusBarHeight(actionBar.getContext())
                            : 0;
            if (actionBar.getLayoutParams() != null) {
                actionBar.getLayoutParams().height = height + DensityUtil.dip2px(sHeight);
                paddingHeight = height;
                actionBar.setPadding(0, height, 0, 0);
            }
        }
    }

    public static void setStatusBarTopPadding(View actionBar) {
        if (actionBar != null && actionBar.getContext() != null) {
            int height =
                    Build.VERSION.SDK_INT >= 19 ? StatusBarUtils.getStatusBarHeight(actionBar.getContext())
                            : 0;
            paddingHeight = height;
            actionBar.setPadding(0, height, 0, 0);
        }
    }
}
